package search

type SSeqSearch struct {
	sList []int
}

func NewSSeqSearch(list []int) *SSeqSearch {
	seq := &SSeqSearch{
		sList: make([]int, 0, len(list)+1),
	}

	seq.sList = append(seq.sList, 0) //0号位置存哨兵
	seq.sList = append(seq.sList, list...)

	return seq
}

/**
返回找到位置的下标，没有找到返回0
*/
func (seq *SSeqSearch) Search(value int) int {
	seq.sList[0] = value
	i := len(seq.sList) - 1
	for ; seq.sList[i] != value; i-- {
	}
	return i
}
